package fr.castorhoz.isi_connectivity_widget;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.graphics.drawable.Drawable;

public abstract class ConnButton {
	public static int selector_on;
	public static int selector_off;
	public static int selector_unknown;
	public static int STATE_ON = 1;
	public static int STATE_OFF = 0;
	protected int state;
	protected BroadcastReceiver receiver;
	
	public enum widgets {
		bluetoohWidget,
		wifiWidget,
		mobileDataWidget,
		gpsWidget,
		roamingWidget;
		public static int getAdaptedDrawableId(String widgetName) {
			int retour = -1;
			switch (widgets.valueOf(widgetName)) {
			case bluetoohWidget:
				retour = R.drawable.bluetoothwidget;
				break;
			case gpsWidget:
				retour = R.drawable.gpswidget;
				break;
			case mobileDataWidget:
				retour = R.drawable.mobiledatawidget;
				break;
			case roamingWidget:
				retour = R.drawable.roamingwidget;
				break;
			case wifiWidget:
				retour = R.drawable.wifiwidget;
				break;

			default:
				break;
			}
			return retour;		
		}
		
	};
	
	public void switchNetwork(Context c) {
		if (state == STATE_ON)
			disableNetwork(c);
		else
			enableNetwork(c);
	}

	public abstract void disableNetwork(Context c);

	public abstract void enableNetwork(Context c);

	public abstract String getAction();
	
	public abstract int getSelectorUnknown();
	
	public abstract int getSelectorOn();
	
	public abstract int getSelectorOff();

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}	

}
